﻿using ProjectFootball.MVC.Areas.MatchArea.Models;
using ProjectFootball.MVC.Models.EntityFramework.Entities;
using System.Collections.Generic;
using System.Security.Principal;

namespace ProjectFootball.MVC.Models.EntityFramework.Entities
{
    public static class _MatchEventExtensions
    {
        public static MatchEventDataModel GetDataModel(this MatchEvent matchEvent)
        {
            return new MatchEventDataModel()
            {
                MatchEventGuid = matchEvent.Pk,
                ApprovalGuid = matchEvent.ApprovalGuid,
                MatchGuid = matchEvent.MatchGuid,
                TeamGuid = matchEvent.TeamGuid,
                PersonGuid = matchEvent.PersonGuid,
                MatchEventType = matchEvent.MatchEventType,
                Minute = matchEvent.Minute,
                Extra = matchEvent.Extra,
            };
        }

        public static IEnumerable<MatchEventDataModel> GetDataModels(this IEnumerable<MatchEvent> matchEvents, IPrincipal user)
        {
            foreach (MatchEvent matchEvent in matchEvents)
                yield return matchEvent.GetDataModel();
        }
    }
}